import React, { Component } from 'react'
import Home from './Home'
import eventBus from './utils/event-bus'
export class App extends Component {
  constructor() {
    super()
    this.state = {
      name: '',
      ahe: 0,
      height:0
    }
  }
  prevClick(name,age,height) {
    console.log(this); // undefined
    this.setState({name,age,height})
  }
  componentDidMount() {
    eventBus.on('prevClick',this.prevClick,this)
  }
  componentWillUnmount() {
    eventBus.off('prevClick',this.prevClick)
  }
  render() {
    const {name, age, height} = this.state
    return (
      <div>
        <div>my name is {name},age is {age}, height is { height}</div>
        <Home/>
      </div>
    )
  }
}

export default App